# 位置传参
def happy_birthday(name, age):
    print('祝', name, age, '岁', '生日快乐')


happy_birthday('小刘', 22)

# 关键字传参
happy_birthday(age=25, name='马迪迪')

# 复合使用，位置参数在前，关键字参数在后
happy_birthday('小可爱', 28)


# 默认值传参
def happy_birthday_you(name='蔡玉坤', age=25):
    print('祝', name, age, '岁', '生日快乐')


# 默认值传参
happy_birthday_you()
happy_birthday_you(name='蔡徐坤')
happy_birthday_you('徐坤', age=35)


# 个数可变的位置参数
def fun(*param):
    print(type(param))
    print(param)
    for i in param:
        print(i)


# 调用
fun(1, 2, 3, 4, 5, 6, 7, 8, 9)
fun(1)
fun(1, 2)
fun([1, 2, 3, 4, 5, 6, 7, 8, 9])
fun(*[1, 2, 3, 4, 5, 6, 7, 8, 9])

print('*' * 20)


# 个数可变的关键数参数
def fun2(**param):
    print(type(param))
    for i, item in enumerate(param):
        print(i, item, param[item])
    for key, var in param.items():
        print(key, var)


fun2(a=1, b=2, c=3)

dictData = {'a': 1, 'b': 2, 'c': 3}
print(dictData.get('a'))
# 可以使用**的方式解包方式使用
fun2(**dictData)
